﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.ComponentModel;
using System.Collections.ObjectModel;


namespace HomeWP
{
    [global::System.Data.Linq.Mapping.TableAttribute(Name = "")]
    public partial class Device : INotifyPropertyChanging, INotifyPropertyChanged
    {

        private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

        private string _Address;

        private string _State;

        private string _Parent;

        private string _Type;

        private string _ParentType;

        private string _Firmware;

        private System.Nullable<int> _Direction;

        private System.Nullable<int> _Version;

        private System.Nullable<int> _Flags;

        private string _LINK_SOURCE_ROLES;

        private string _LINK_TARGET_ROLES;

        private string _Group;

        private string _Team;

        private string _Team_TAG;

        private string _Interface;

        private System.Nullable<bool> _Roaming;

        private string _Paramset;

        private System.DateTime _Modified;

        private string _DisplayName;

        private string _Bus;

        private EntitySet<ParamSet> _ParamSets;

        private EntitySet<Children> _Childrens;

        #region Extensibility Method Definitions
        partial void OnLoaded();
        partial void OnValidate(System.Data.Linq.ChangeAction action);
        partial void OnCreated();
        partial void OnAddressChanging(string value);
        partial void OnAddressChanged();
        partial void OnStateChanging(string value);
        partial void OnStateChanged();
        partial void OnParentChanging(string value);
        partial void OnParentChanged();
        partial void OnTypeChanging(string value);
        partial void OnTypeChanged();
        partial void OnParentTypeChanging(string value);
        partial void OnParentTypeChanged();
        partial void OnFirmwareChanging(string value);
        partial void OnFirmwareChanged();
        partial void OnDirectionChanging(System.Nullable<int> value);
        partial void OnDirectionChanged();
        partial void OnVersionChanging(System.Nullable<int> value);
        partial void OnVersionChanged();
        partial void OnFlagsChanging(System.Nullable<int> value);
        partial void OnFlagsChanged();
        partial void OnLINK_SOURCE_ROLESChanging(string value);
        partial void OnLINK_SOURCE_ROLESChanged();
        partial void OnLINK_TARGET_ROLESChanging(string value);
        partial void OnLINK_TARGET_ROLESChanged();
        partial void OnGroupChanging(string value);
        partial void OnGroupChanged();
        partial void OnTeamChanging(string value);
        partial void OnTeamChanged();
        partial void OnTeam_TAGChanging(string value);
        partial void OnTeam_TAGChanged();
        partial void OnInterfaceChanging(string value);
        partial void OnInterfaceChanged();
        partial void OnRoamingChanging(System.Nullable<bool> value);
        partial void OnRoamingChanged();
        partial void OnParamsetChanging(string value);
        partial void OnParamsetChanged();
        partial void OnModifiedChanging(System.DateTime value);
        partial void OnModifiedChanged();
        partial void OnDisplayNameChanging(string value);
        partial void OnDisplayNameChanged();
        partial void OnBusChanging(string value);
        partial void OnBusChanged();
        #endregion

        public Device()
        {
            this._ParamSets = new EntitySet<ParamSet>(new Action<ParamSet>(this.attach_ParamSets), new Action<ParamSet>(this.detach_ParamSets));
            this._Childrens = new EntitySet<Children>(new Action<Children>(this.attach_Childrens), new Action<Children>(this.detach_Childrens));
            OnCreated();
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Address", CanBeNull = false, IsPrimaryKey = true)]
        public string Address
        {
            get
            {
                return this._Address;
            }
            set
            {
                if ((this._Address != value))
                {
                    this.OnAddressChanging(value);
                    this.SendPropertyChanging();
                    this._Address = value;
                    this.SendPropertyChanged("Address");
                    this.OnAddressChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_State")]
        public string State
        {
            get
            {
                return this._State;
            }
            set
            {
                if ((this._State != value))
                {
                    this.OnStateChanging(value);
                    this.SendPropertyChanging();
                    this._State = value;
                    this.SendPropertyChanged("State");
                    this.OnStateChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Parent")]
        public string Parent
        {
            get
            {
                return this._Parent;
            }
            set
            {
                if ((this._Parent != value))
                {
                    this.OnParentChanging(value);
                    this.SendPropertyChanging();
                    this._Parent = value;
                    this.SendPropertyChanged("Parent");
                    this.OnParentChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Type")]
        public string Type
        {
            get
            {
                return this._Type;
            }
            set
            {
                if ((this._Type != value))
                {
                    this.OnTypeChanging(value);
                    this.SendPropertyChanging();
                    this._Type = value;
                    this.SendPropertyChanged("Type");
                    this.OnTypeChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_ParentType")]
        public string ParentType
        {
            get
            {
                return this._ParentType;
            }
            set
            {
                if ((this._ParentType != value))
                {
                    this.OnParentTypeChanging(value);
                    this.SendPropertyChanging();
                    this._ParentType = value;
                    this.SendPropertyChanged("ParentType");
                    this.OnParentTypeChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Firmware")]
        public string Firmware
        {
            get
            {
                return this._Firmware;
            }
            set
            {
                if ((this._Firmware != value))
                {
                    this.OnFirmwareChanging(value);
                    this.SendPropertyChanging();
                    this._Firmware = value;
                    this.SendPropertyChanged("Firmware");
                    this.OnFirmwareChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Direction")]
        public System.Nullable<int> Direction
        {
            get
            {
                return this._Direction;
            }
            set
            {
                if ((this._Direction != value))
                {
                    this.OnDirectionChanging(value);
                    this.SendPropertyChanging();
                    this._Direction = value;
                    this.SendPropertyChanged("Direction");
                    this.OnDirectionChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Version")]
        public System.Nullable<int> Version
        {
            get
            {
                return this._Version;
            }
            set
            {
                if ((this._Version != value))
                {
                    this.OnVersionChanging(value);
                    this.SendPropertyChanging();
                    this._Version = value;
                    this.SendPropertyChanged("Version");
                    this.OnVersionChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Flags")]
        public System.Nullable<int> Flags
        {
            get
            {
                return this._Flags;
            }
            set
            {
                if ((this._Flags != value))
                {
                    this.OnFlagsChanging(value);
                    this.SendPropertyChanging();
                    this._Flags = value;
                    this.SendPropertyChanged("Flags");
                    this.OnFlagsChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_LINK_SOURCE_ROLES")]
        public string LINK_SOURCE_ROLES
        {
            get
            {
                return this._LINK_SOURCE_ROLES;
            }
            set
            {
                if ((this._LINK_SOURCE_ROLES != value))
                {
                    this.OnLINK_SOURCE_ROLESChanging(value);
                    this.SendPropertyChanging();
                    this._LINK_SOURCE_ROLES = value;
                    this.SendPropertyChanged("LINK_SOURCE_ROLES");
                    this.OnLINK_SOURCE_ROLESChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_LINK_TARGET_ROLES")]
        public string LINK_TARGET_ROLES
        {
            get
            {
                return this._LINK_TARGET_ROLES;
            }
            set
            {
                if ((this._LINK_TARGET_ROLES != value))
                {
                    this.OnLINK_TARGET_ROLESChanging(value);
                    this.SendPropertyChanging();
                    this._LINK_TARGET_ROLES = value;
                    this.SendPropertyChanged("LINK_TARGET_ROLES");
                    this.OnLINK_TARGET_ROLESChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Group")]
        public string Group
        {
            get
            {
                return this._Group;
            }
            set
            {
                if ((this._Group != value))
                {
                    this.OnGroupChanging(value);
                    this.SendPropertyChanging();
                    this._Group = value;
                    this.SendPropertyChanged("Group");
                    this.OnGroupChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Team")]
        public string Team
        {
            get
            {
                return this._Team;
            }
            set
            {
                if ((this._Team != value))
                {
                    this.OnTeamChanging(value);
                    this.SendPropertyChanging();
                    this._Team = value;
                    this.SendPropertyChanged("Team");
                    this.OnTeamChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Team_TAG")]
        public string Team_TAG
        {
            get
            {
                return this._Team_TAG;
            }
            set
            {
                if ((this._Team_TAG != value))
                {
                    this.OnTeam_TAGChanging(value);
                    this.SendPropertyChanging();
                    this._Team_TAG = value;
                    this.SendPropertyChanged("Team_TAG");
                    this.OnTeam_TAGChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Interface")]
        public string Interface
        {
            get
            {
                return this._Interface;
            }
            set
            {
                if ((this._Interface != value))
                {
                    this.OnInterfaceChanging(value);
                    this.SendPropertyChanging();
                    this._Interface = value;
                    this.SendPropertyChanged("Interface");
                    this.OnInterfaceChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Roaming")]
        public System.Nullable<bool> Roaming
        {
            get
            {
                return this._Roaming;
            }
            set
            {
                if ((this._Roaming != value))
                {
                    this.OnRoamingChanging(value);
                    this.SendPropertyChanging();
                    this._Roaming = value;
                    this.SendPropertyChanged("Roaming");
                    this.OnRoamingChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Paramset")]
        public string Paramset
        {
            get
            {
                return this._Paramset;
            }
            set
            {
                if ((this._Paramset != value))
                {
                    this.OnParamsetChanging(value);
                    this.SendPropertyChanging();
                    this._Paramset = value;
                    this.SendPropertyChanged("Paramset");
                    this.OnParamsetChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Modified")]
        public System.DateTime Modified
        {
            get
            {
                return this._Modified;
            }
            set
            {
                if ((this._Modified != value))
                {
                    this.OnModifiedChanging(value);
                    this.SendPropertyChanging();
                    this._Modified = value;
                    this.SendPropertyChanged("Modified");
                    this.OnModifiedChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_DisplayName")]
        public string DisplayName
        {
            get
            {
                return this._DisplayName;
            }
            set
            {
                if ((this._DisplayName != value))
                {
                    this.OnDisplayNameChanging(value);
                    this.SendPropertyChanging();
                    this._DisplayName = value;
                    this.SendPropertyChanged("DisplayName");
                    this.OnDisplayNameChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Bus", CanBeNull = false)]
        public string Bus
        {
            get
            {
                return this._Bus;
            }
            set
            {
                if ((this._Bus != value))
                {
                    this.OnBusChanging(value);
                    this.SendPropertyChanging();
                    this._Bus = value;
                    this.SendPropertyChanged("Bus");
                    this.OnBusChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.AssociationAttribute(Name = "Device_ParamSet", Storage = "_ParamSets", ThisKey = "Address", OtherKey = "Address")]
        public EntitySet<ParamSet> ParamSets
        {
            get
            {
                return this._ParamSets;
            }
            set
            {
                this._ParamSets.Assign(value);
            }
        }

        [global::System.Data.Linq.Mapping.AssociationAttribute(Name = "Device_Children", Storage = "_Childrens", ThisKey = "Address", OtherKey = "ParentAddress")]
        public EntitySet<Children> Childrens
        {
            get
            {
                return this._Childrens;
            }
            set
            {
                this._Childrens.Assign(value);
            }
        }

        public event PropertyChangingEventHandler PropertyChanging;

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void SendPropertyChanging()
        {
            if ((this.PropertyChanging != null))
            {
                this.PropertyChanging(this, emptyChangingEventArgs);
            }
        }

        protected virtual void SendPropertyChanged(String propertyName)
        {
            if ((this.PropertyChanged != null))
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        private void attach_ParamSets(ParamSet entity)
        {
            this.SendPropertyChanging();
            entity.Device = this;
        }

        private void detach_ParamSets(ParamSet entity)
        {
            this.SendPropertyChanging();
            entity.Device = null;
        }

        private void attach_Childrens(Children entity)
        {
            this.SendPropertyChanging();
            entity.Device = this;
        }

        private void detach_Childrens(Children entity)
        {
            this.SendPropertyChanging();
            entity.Device = null;
        }
    }

    [global::System.Data.Linq.Mapping.TableAttribute(Name = "")]
    public partial class DeviceRoom : INotifyPropertyChanging, INotifyPropertyChanged
    {

        private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

        private string _Address;

        private string _RoomName;

        private System.Nullable<System.DateTime> _Modified;

        #region Extensibility Method Definitions
        partial void OnLoaded();
        partial void OnValidate(System.Data.Linq.ChangeAction action);
        partial void OnCreated();
        partial void OnAddressChanging(string value);
        partial void OnAddressChanged();
        partial void OnRoomNameChanging(string value);
        partial void OnRoomNameChanged();
        partial void OnModifiedChanging(System.Nullable<System.DateTime> value);
        partial void OnModifiedChanged();
        #endregion

        public DeviceRoom()
        {
            OnCreated();
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Address", CanBeNull = false, IsPrimaryKey = true)]
        public string Address
        {
            get
            {
                return this._Address;
            }
            set
            {
                if ((this._Address != value))
                {
                    this.OnAddressChanging(value);
                    this.SendPropertyChanging();
                    this._Address = value;
                    this.SendPropertyChanged("Address");
                    this.OnAddressChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_RoomName", CanBeNull = false, IsPrimaryKey = true)]
        public string RoomName
        {
            get
            {
                return this._RoomName;
            }
            set
            {
                if ((this._RoomName != value))
                {
                    this.OnRoomNameChanging(value);
                    this.SendPropertyChanging();
                    this._RoomName = value;
                    this.SendPropertyChanged("RoomName");
                    this.OnRoomNameChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Modified")]
        public System.Nullable<System.DateTime> Modified
        {
            get
            {
                return this._Modified;
            }
            set
            {
                if ((this._Modified != value))
                {
                    this.OnModifiedChanging(value);
                    this.SendPropertyChanging();
                    this._Modified = value;
                    this.SendPropertyChanged("Modified");
                    this.OnModifiedChanged();
                }
            }
        }

        public event PropertyChangingEventHandler PropertyChanging;

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void SendPropertyChanging()
        {
            if ((this.PropertyChanging != null))
            {
                this.PropertyChanging(this, emptyChangingEventArgs);
            }
        }

        protected virtual void SendPropertyChanged(String propertyName)
        {
            if ((this.PropertyChanged != null))
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }

    [global::System.Data.Linq.Mapping.TableAttribute(Name = "")]
    public partial class ParamSet : INotifyPropertyChanging, INotifyPropertyChanged
    {

        private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

        private string _Address;

        private string _Parameter;

        private string _Type;

        private string _ParamsetType;

        private string _Unit;

        private string _Value;

        private System.Nullable<bool> _isReadonly;

        private string _MinValue;

        private string _MaxValue;

        private EntityRef<Device> _Device;

        #region Extensibility Method Definitions
        partial void OnLoaded();
        partial void OnValidate(System.Data.Linq.ChangeAction action);
        partial void OnCreated();
        partial void OnAddressChanging(string value);
        partial void OnAddressChanged();
        partial void OnParameterChanging(string value);
        partial void OnParameterChanged();
        partial void OnTypeChanging(string value);
        partial void OnTypeChanged();
        partial void OnParamsetTypeChanging(string value);
        partial void OnParamsetTypeChanged();
        partial void OnUnitChanging(string value);
        partial void OnUnitChanged();
        partial void OnValueChanging(string value);
        partial void OnValueChanged();
        partial void OnisReadonlyChanging(System.Nullable<bool> value);
        partial void OnisReadonlyChanged();
        partial void OnMinValueChanging(string value);
        partial void OnMinValueChanged();
        partial void OnMaxValueChanging(string value);
        partial void OnMaxValueChanged();
        #endregion

        public ParamSet()
        {
            this._Device = default(EntityRef<Device>);
            OnCreated();
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Address", CanBeNull = false, IsPrimaryKey = true)]
        public string Address
        {
            get
            {
                return this._Address;
            }
            set
            {
                if ((this._Address != value))
                {
                    if (this._Device.HasLoadedOrAssignedValue)
                    {
                        throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
                    }
                    this.OnAddressChanging(value);
                    this.SendPropertyChanging();
                    this._Address = value;
                    this.SendPropertyChanged("Address");
                    this.OnAddressChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Parameter", CanBeNull = false, IsPrimaryKey = true)]
        public string Parameter
        {
            get
            {
                return this._Parameter;
            }
            set
            {
                if ((this._Parameter != value))
                {
                    this.OnParameterChanging(value);
                    this.SendPropertyChanging();
                    this._Parameter = value;
                    this.SendPropertyChanged("Parameter");
                    this.OnParameterChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Type")]
        public string Type
        {
            get
            {
                return this._Type;
            }
            set
            {
                if ((this._Type != value))
                {
                    this.OnTypeChanging(value);
                    this.SendPropertyChanging();
                    this._Type = value;
                    this.SendPropertyChanged("Type");
                    this.OnTypeChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_ParamsetType")]
        public string ParamsetType
        {
            get
            {
                return this._ParamsetType;
            }
            set
            {
                if ((this._ParamsetType != value))
                {
                    this.OnParamsetTypeChanging(value);
                    this.SendPropertyChanging();
                    this._ParamsetType = value;
                    this.SendPropertyChanged("ParamsetType");
                    this.OnParamsetTypeChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Unit")]
        public string Unit
        {
            get
            {
                return this._Unit;
            }
            set
            {
                if ((this._Unit != value))
                {
                    this.OnUnitChanging(value);
                    this.SendPropertyChanging();
                    this._Unit = value;
                    this.SendPropertyChanged("Unit");
                    this.OnUnitChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Value")]
        public string Value
        {
            get
            {
                return this._Value;
            }
            set
            {
                if ((this._Value != value))
                {
                    this.OnValueChanging(value);
                    this.SendPropertyChanging();
                    this._Value = value;
                    this.SendPropertyChanged("Value");
                    this.OnValueChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_isReadonly")]
        public System.Nullable<bool> isReadonly
        {
            get
            {
                return this._isReadonly;
            }
            set
            {
                if ((this._isReadonly != value))
                {
                    this.OnisReadonlyChanging(value);
                    this.SendPropertyChanging();
                    this._isReadonly = value;
                    this.SendPropertyChanged("isReadonly");
                    this.OnisReadonlyChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_MinValue")]
        public string MinValue
        {
            get
            {
                return this._MinValue;
            }
            set
            {
                if ((this._MinValue != value))
                {
                    this.OnMinValueChanging(value);
                    this.SendPropertyChanging();
                    this._MinValue = value;
                    this.SendPropertyChanged("MinValue");
                    this.OnMinValueChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_MaxValue")]
        public string MaxValue
        {
            get
            {
                return this._MaxValue;
            }
            set
            {
                if ((this._MaxValue != value))
                {
                    this.OnMaxValueChanging(value);
                    this.SendPropertyChanging();
                    this._MaxValue = value;
                    this.SendPropertyChanged("MaxValue");
                    this.OnMaxValueChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.AssociationAttribute(Name = "Device_ParamSet", Storage = "_Device", ThisKey = "Address", OtherKey = "Address", IsForeignKey = true)]
        public Device Device
        {
            get
            {
                return this._Device.Entity;
            }
            set
            {
                Device previousValue = this._Device.Entity;
                if (((previousValue != value)
                            || (this._Device.HasLoadedOrAssignedValue == false)))
                {
                    this.SendPropertyChanging();
                    if ((previousValue != null))
                    {
                        this._Device.Entity = null;
                        previousValue.ParamSets.Remove(this);
                    }
                    this._Device.Entity = value;
                    if ((value != null))
                    {
                        value.ParamSets.Add(this);
                        this._Address = value.Address;
                    }
                    else
                    {
                        this._Address = default(string);
                    }
                    this.SendPropertyChanged("Device");
                }
            }
        }

        public event PropertyChangingEventHandler PropertyChanging;

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void SendPropertyChanging()
        {
            if ((this.PropertyChanging != null))
            {
                this.PropertyChanging(this, emptyChangingEventArgs);
            }
        }

        protected virtual void SendPropertyChanged(String propertyName)
        {
            if ((this.PropertyChanged != null))
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }

    [global::System.Data.Linq.Mapping.TableAttribute(Name = "")]
    public partial class Children : INotifyPropertyChanging, INotifyPropertyChanged
    {

        private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

        private string _ParentAddress;

        private string _ChildAddress;

        private EntityRef<Device> _Device;

        #region Extensibility Method Definitions
        partial void OnLoaded();
        partial void OnValidate(System.Data.Linq.ChangeAction action);
        partial void OnCreated();
        partial void OnParentAddressChanging(string value);
        partial void OnParentAddressChanged();
        partial void OnChildAddressChanging(string value);
        partial void OnChildAddressChanged();
        #endregion

        public Children()
        {
            this._Device = default(EntityRef<Device>);
            OnCreated();
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_ParentAddress", CanBeNull = false, IsPrimaryKey = true)]
        public string ParentAddress
        {
            get
            {
                return this._ParentAddress;
            }
            set
            {
                if ((this._ParentAddress != value))
                {
                    if (this._Device.HasLoadedOrAssignedValue)
                    {
                        throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
                    }
                    this.OnParentAddressChanging(value);
                    this.SendPropertyChanging();
                    this._ParentAddress = value;
                    this.SendPropertyChanged("ParentAddress");
                    this.OnParentAddressChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_ChildAddress", CanBeNull = false, IsPrimaryKey = true)]
        public string ChildAddress
        {
            get
            {
                return this._ChildAddress;
            }
            set
            {
                if ((this._ChildAddress != value))
                {
                    this.OnChildAddressChanging(value);
                    this.SendPropertyChanging();
                    this._ChildAddress = value;
                    this.SendPropertyChanged("ChildAddress");
                    this.OnChildAddressChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.AssociationAttribute(Name = "Device_Children", Storage = "_Device", ThisKey = "ParentAddress", OtherKey = "Address", IsForeignKey = true)]
        public Device Device
        {
            get
            {
                return this._Device.Entity;
            }
            set
            {
                Device previousValue = this._Device.Entity;
                if (((previousValue != value)
                            || (this._Device.HasLoadedOrAssignedValue == false)))
                {
                    this.SendPropertyChanging();
                    if ((previousValue != null))
                    {
                        this._Device.Entity = null;
                        previousValue.Childrens.Remove(this);
                    }
                    this._Device.Entity = value;
                    if ((value != null))
                    {
                        value.Childrens.Add(this);
                        this._ParentAddress = value.Address;
                    }
                    else
                    {
                        this._ParentAddress = default(string);
                    }
                    this.SendPropertyChanged("Device");
                }
            }
        }

        public event PropertyChangingEventHandler PropertyChanging;

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void SendPropertyChanging()
        {
            if ((this.PropertyChanging != null))
            {
                this.PropertyChanging(this, emptyChangingEventArgs);
            }
        }

        protected virtual void SendPropertyChanged(String propertyName)
        {
            if ((this.PropertyChanged != null))
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }

    [global::System.Data.Linq.Mapping.TableAttribute(Name = "")]
    public partial class DeviceFunction : INotifyPropertyChanging, INotifyPropertyChanged
    {

        private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

        private string _Address;

        private string _Function;

        private System.Nullable<System.DateTime> _Modified;

        #region Extensibility Method Definitions
        partial void OnLoaded();
        partial void OnValidate(System.Data.Linq.ChangeAction action);
        partial void OnCreated();
        partial void OnAddressChanging(string value);
        partial void OnAddressChanged();
        partial void OnFunctionChanging(string value);
        partial void OnFunctionChanged();
        partial void OnModifiedChanging(System.Nullable<System.DateTime> value);
        partial void OnModifiedChanged();
        #endregion

        public DeviceFunction()
        {
            OnCreated();
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Address", CanBeNull = false, IsPrimaryKey = true)]
        public string Address
        {
            get
            {
                return this._Address;
            }
            set
            {
                if ((this._Address != value))
                {
                    this.OnAddressChanging(value);
                    this.SendPropertyChanging();
                    this._Address = value;
                    this.SendPropertyChanged("Address");
                    this.OnAddressChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Function", CanBeNull = false, IsPrimaryKey = true)]
        public string Function
        {
            get
            {
                return this._Function;
            }
            set
            {
                if ((this._Function != value))
                {
                    this.OnFunctionChanging(value);
                    this.SendPropertyChanging();
                    this._Function = value;
                    this.SendPropertyChanged("Function");
                    this.OnFunctionChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Modified")]
        public System.Nullable<System.DateTime> Modified
        {
            get
            {
                return this._Modified;
            }
            set
            {
                if ((this._Modified != value))
                {
                    this.OnModifiedChanging(value);
                    this.SendPropertyChanging();
                    this._Modified = value;
                    this.SendPropertyChanged("Modified");
                    this.OnModifiedChanged();
                }
            }
        }

        public event PropertyChangingEventHandler PropertyChanging;

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void SendPropertyChanging()
        {
            if ((this.PropertyChanging != null))
            {
                this.PropertyChanging(this, emptyChangingEventArgs);
            }
        }

        protected virtual void SendPropertyChanged(String propertyName)
        {
            if ((this.PropertyChanged != null))
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }

    [global::System.Data.Linq.Mapping.TableAttribute(Name = "")]
    public partial class CCUSettings : INotifyPropertyChanging, INotifyPropertyChanged
    {

        private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

        private string _CCU;

        private int _Port;

        private string _ConfigID;

        private System.DateTime _Modified;

        private int _Timeout;

        #region Extensibility Method Definitions
        partial void OnLoaded();
        partial void OnValidate(System.Data.Linq.ChangeAction action);
        partial void OnCreated();
        partial void OnCCUChanging(string value);
        partial void OnCCUChanged();
        partial void OnPortChanging(int value);
        partial void OnPortChanged();
        partial void OnConfigIDChanging(string value);
        partial void OnConfigIDChanged();
        partial void OnModifiedChanging(System.DateTime value);
        partial void OnModifiedChanged();
        partial void OnTimeoutChanging(int value);
        partial void OnTimeoutChanged();
        #endregion

        public CCUSettings()
        {
            OnCreated();
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_CCU", CanBeNull = false)]
        public string CCU
        {
            get
            {
                return this._CCU;
            }
            set
            {
                if ((this._CCU != value))
                {
                    this.OnCCUChanging(value);
                    this.SendPropertyChanging();
                    this._CCU = value;
                    this.SendPropertyChanged("CCU");
                    this.OnCCUChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Port")]
        public int Port
        {
            get
            {
                return this._Port;
            }
            set
            {
                if ((this._Port != value))
                {
                    this.OnPortChanging(value);
                    this.SendPropertyChanging();
                    this._Port = value;
                    this.SendPropertyChanged("Port");
                    this.OnPortChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_ConfigID", CanBeNull = false, IsPrimaryKey = true)]
        public string ConfigID
        {
            get
            {
                return this._ConfigID;
            }
            set
            {
                if ((this._ConfigID != value))
                {
                    this.OnConfigIDChanging(value);
                    this.SendPropertyChanging();
                    this._ConfigID = value;
                    this.SendPropertyChanged("ConfigID");
                    this.OnConfigIDChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Modified")]
        public System.DateTime Modified
        {
            get
            {
                return this._Modified;
            }
            set
            {
                if ((this._Modified != value))
                {
                    this.OnModifiedChanging(value);
                    this.SendPropertyChanging();
                    this._Modified = value;
                    this.SendPropertyChanged("Modified");
                    this.OnModifiedChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Timeout")]
        public int Timeout
        {
            get
            {
                return this._Timeout;
            }
            set
            {
                if ((this._Timeout != value))
                {
                    this.OnTimeoutChanging(value);
                    this.SendPropertyChanging();
                    this._Timeout = value;
                    this.SendPropertyChanged("Timeout");
                    this.OnTimeoutChanged();
                }
            }
        }

        public event PropertyChangingEventHandler PropertyChanging;

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void SendPropertyChanging()
        {
            if ((this.PropertyChanging != null))
            {
                this.PropertyChanging(this, emptyChangingEventArgs);
            }
        }

        protected virtual void SendPropertyChanged(String propertyName)
        {
            if ((this.PropertyChanged != null))
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }

    [global::System.Data.Linq.Mapping.TableAttribute(Name = "")]
    public partial class SystemVariable : INotifyPropertyChanging, INotifyPropertyChanged
    {

        private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

        private string _Name;

        private string _Value;

        private int _ValueType;

        private int _ID;

        private string _Min;

        private string _Max;

        private string _Unit;

        private System.Nullable<bool> _Visible;

        private System.Nullable<bool> _Logged;

        private string _ValueList;

        private System.DateTime _Timestamp;

        private int _Subtype;

        #region Extensibility Method Definitions
        partial void OnLoaded();
        partial void OnValidate(System.Data.Linq.ChangeAction action);
        partial void OnCreated();
        partial void OnNameChanging(string value);
        partial void OnNameChanged();
        partial void OnValueChanging(string value);
        partial void OnValueChanged();
        partial void OnValueTypeChanging(int value);
        partial void OnValueTypeChanged();
        partial void OnIDChanging(int value);
        partial void OnIDChanged();
        partial void OnMinChanging(string value);
        partial void OnMinChanged();
        partial void OnMaxChanging(string value);
        partial void OnMaxChanged();
        partial void OnUnitChanging(string value);
        partial void OnUnitChanged();
        partial void OnVisibleChanging(System.Nullable<bool> value);
        partial void OnVisibleChanged();
        partial void OnLoggedChanging(System.Nullable<bool> value);
        partial void OnLoggedChanged();
        partial void OnValueListChanging(string value);
        partial void OnValueListChanged();
        partial void OnTimestampChanging(System.DateTime value);
        partial void OnTimestampChanged();
        partial void OnSubtypeChanging(int value);
        partial void OnSubtypeChanged();
        #endregion

        public SystemVariable()
        {
            OnCreated();
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Name", CanBeNull = false)]
        public string Name
        {
            get
            {
                return this._Name;
            }
            set
            {
                if ((this._Name != value))
                {
                    this.OnNameChanging(value);
                    this.SendPropertyChanging();
                    this._Name = value;
                    this.SendPropertyChanged("Name");
                    this.OnNameChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Value")]
        public string Value
        {
            get
            {
                return this._Value;
            }
            set
            {
                if ((this._Value != value))
                {
                    this.OnValueChanging(value);
                    this.SendPropertyChanging();
                    this._Value = value;
                    this.SendPropertyChanged("Value");
                    this.OnValueChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_ValueType")]
        public int ValueType
        {
            get
            {
                return this._ValueType;
            }
            set
            {
                if ((this._ValueType != value))
                {
                    this.OnValueTypeChanging(value);
                    this.SendPropertyChanging();
                    this._ValueType = value;
                    this.SendPropertyChanged("ValueType");
                    this.OnValueTypeChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_ID", AutoSync = AutoSync.Always, IsPrimaryKey = true)]
        public int ID
        {
            get
            {
                return this._ID;
            }
            set
            {
                if ((this._ID != value))
                {
                    this.OnIDChanging(value);
                    this.SendPropertyChanging();
                    this._ID = value;
                    this.SendPropertyChanged("ID");
                    this.OnIDChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Min")]
        public string Min
        {
            get
            {
                return this._Min;
            }
            set
            {
                if ((this._Min != value))
                {
                    this.OnMinChanging(value);
                    this.SendPropertyChanging();
                    this._Min = value;
                    this.SendPropertyChanged("Min");
                    this.OnMinChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Max")]
        public string Max
        {
            get
            {
                return this._Max;
            }
            set
            {
                if ((this._Max != value))
                {
                    this.OnMaxChanging(value);
                    this.SendPropertyChanging();
                    this._Max = value;
                    this.SendPropertyChanged("Max");
                    this.OnMaxChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Unit")]
        public string Unit
        {
            get
            {
                return this._Unit;
            }
            set
            {
                if ((this._Unit != value))
                {
                    this.OnUnitChanging(value);
                    this.SendPropertyChanging();
                    this._Unit = value;
                    this.SendPropertyChanged("Unit");
                    this.OnUnitChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Visible")]
        public System.Nullable<bool> Visible
        {
            get
            {
                return this._Visible;
            }
            set
            {
                if ((this._Visible != value))
                {
                    this.OnVisibleChanging(value);
                    this.SendPropertyChanging();
                    this._Visible = value;
                    this.SendPropertyChanged("Visible");
                    this.OnVisibleChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Logged")]
        public System.Nullable<bool> Logged
        {
            get
            {
                return this._Logged;
            }
            set
            {
                if ((this._Logged != value))
                {
                    this.OnLoggedChanging(value);
                    this.SendPropertyChanging();
                    this._Logged = value;
                    this.SendPropertyChanged("Logged");
                    this.OnLoggedChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_ValueList")]
        public string ValueList
        {
            get
            {
                return this._ValueList;
            }
            set
            {
                if ((this._ValueList != value))
                {
                    this.OnValueListChanging(value);
                    this.SendPropertyChanging();
                    this._ValueList = value;
                    this.SendPropertyChanged("ValueList");
                    this.OnValueListChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Timestamp")]
        public System.DateTime Timestamp
        {
            get
            {
                return this._Timestamp;
            }
            set
            {
                if ((this._Timestamp != value))
                {
                    this.OnTimestampChanging(value);
                    this.SendPropertyChanging();
                    this._Timestamp = value;
                    this.SendPropertyChanged("Timestamp");
                    this.OnTimestampChanged();
                }
            }
        }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Subtype")]
        public int Subtype
        {
            get
            {
                return this._Subtype;
            }
            set
            {
                if ((this._Subtype != value))
                {
                    this.OnSubtypeChanging(value);
                    this.SendPropertyChanging();
                    this._Subtype = value;
                    this.SendPropertyChanged("Subtype");
                    this.OnSubtypeChanged();
                }
            }
        }

        public event PropertyChangingEventHandler PropertyChanging;

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void SendPropertyChanging()
        {
            if ((this.PropertyChanging != null))
            {
                this.PropertyChanging(this, emptyChangingEventArgs);
            }
        }

        protected virtual void SendPropertyChanged(String propertyName)
        {
            if ((this.PropertyChanged != null))
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }

}
